package model

import "k8s.io/api/extensions/v1beta1"

// pods
type GetPod struct {
	PodName   string `form:"pod_name"  json:"pod_name"`
	Namespace string `form:"namespace" json:"namespace"`
}

/*
type GetPodLog struct {
	PodName       string `form:"pod_name"`
	Namespace     string `form:"namespace"`
	ContainerName string `form:"container_name"`
	Follow        bool   `form:"follow"`
	TailLines     int64  `form:"tailLines"`
	Previous      bool   `form:"previous"`
}

type PodCmdExec struct {
	PodName   string `json:"pod_name"`
	Namespace string `json:"namespace"`
	Cmd       string `json:"cmd"`
}

*/

// deployment
type GetDeployment struct {
	FilterName string `form:"filter_name"`
	Namespace  string `form:"namespace"`
	Page       int    `form:"page"`
	Limit      int    `form:"limit"`
}

type GetDeploymentInfo struct {
	DeploymentName string `form:"deployment_name" json:"deployment_name"`
	Namespace      string `form:"namespace"       json:"namespace"`
}

type ScaleDeployment struct {
	DeploymentName string `form:"deployment_name"`
	Namespace      string `form:"namespace"`
	ScaleNum       int    `form:"scale_num"`
}

type DeployCreate struct {
	Name           string                          `json:"name"`
	Namespace      string                          `json:"namespace"`
	Replicas       int32                           `json:"replicas"`
	Image          string                          `json:"image"`
	Env            map[string][]*EnvList           `json:"env"`
	Label          map[string]string               `json:"label"`
	LimitsCpu      string                          `json:"limits_cpu"`
	LimitsMemory   string                          `json:"limits_memory"`
	RequestsCpu    string                          `json:"requests_cpu"`
	RequestsMemory string                          `json:"requests_memory"`
	ContainerPort  map[string][]*ContainerPortList `json:"container_port"`
	HealthPort     int32                           `json:"health_port"`
	HealthCheck    bool                            `json:"health_check"`
	HealthPath     string                          `json:"health_path"`
}

type EnvList struct {
	EnvKey   string `json:"env_key"`
	EnvValue string `json:"env_value"`
}

type ContainerPortList struct {
	ContainerPortName string `json:"container_port_name"`
	ContainerPort     int32  `json:"container_port"`
}

// namespace
type GetNameSpace struct {
	NamespaceName string `form:"namespace_name" json:"namespace_name"`
}

type CreateNamespace struct {
	Name           string `json:"name"`
	LimitsCpu      string `json:"limits_cpu"`
	LimitsMemory   string `json:"limits_memory"`
	RequestsCpu    string `json:"requests_cpu"`
	RequestsMemory string `json:"requests_memory"`
}

// nodes
type GetNodes struct {
	NodesName string `form:"nodes_name"`
}

// service
type GetServices struct {
	ServiceName string `form:"service_name" json:"service_name"`
	Namespace   string `form:"namespace"    json:"namespace"`
}

type ServiceCreate struct {
	Name            string                    `json:"name"`
	Namespace       string                    `json:"namespace"`
	Type            string                    `json:"type"`
	ServicePortList map[string][]*ServicePort `json:"service_port_list"`
	Label           map[string]string         `json:"label"`
}

type ServicePort struct {
	PortName      string `json:"port_name"`
	Port          int32  `json:"port"`
	ContainerPort int32  `json:"container_port"`
	NodePort      int32  `json:"node_port"`
}

type SvcPortQuery struct {
	Port int32 `json:"port"`
}

// ingress
type GetIngress struct {
	IngressName string `form:"ingress_name" json:"ingress_name"`
	Namespace   string `form:"namespace"    json:"namespace"`
}

type IngressCreate struct {
	Name      string                 `json:"name"`
	Namespace string                 `json:"namespace"`
	Label     map[string]string      `json:"label"`
	Hosts     map[string][]*HttpPath `json:"hosts"`
}

type HttpPath struct {
	Path        string           `json:"path"`
	PathType    v1beta1.PathType `json:"path_type"`
	ServiceName string           `json:"service_name"`
	ServicePort int              `json:"service_port"`
}

// daemonset
type GetDaemonset struct {
	DaemonSetName string `form:"daemonset_name" json:"daemonset_name"`
	Namespace     string `form:"namespace"      json:"namespace"`
}

// pv
type GetPv struct {
	PvName string `form:"pv_name" json:"pv_name"`
}

// pvc
type GetPvc struct {
	PvcName   string `form:"pvc_name"  json:"pvc_name"`
	Namespace string `form:"namespace" json:"namespace"`
}

// statefulset
type GetStatefulset struct {
	StatefulSetName string `form:"statefulset_name" json:"statefulset_name"`
	Namespace       string `form:"namespace"        json:"namespace"`
}

// configmap
type GetConfigMap struct {
	ConfigMapName string `form:"configmap_name" json:"configmap_name"`
	Namespace     string `form:"namespace"      json:"namespace"`
}

// secret
type GetSecret struct {
	SecretName string `form:"secret_name" json:"secret_name"`
	Namespace  string `form:"namespace"   json:"namespace"`
}

// yaml
type YamlApplyForm struct {
	Kind      string      `json:"kind"      form:"kind"`
	Name      string      `json:"name"      form:"name"`
	Namespace string      `json:"namespace" form:"namespace"`
	Yaml      interface{} `json:"yaml"      form:"yaml" binding:"required"`
}

type YamlCreateForm struct {
	Kind      string      `json:"kind"      form:"kind"`
	Namespace string      `json:"namespace" form:"namespace"`
	Yaml      interface{} `json:"yaml"      form:"yaml" binding:"required"`
}
